#ifndef COMM_INSTRUMENT_H_
#define COMM_INSTRUMENT_H_

#include <string>
#include <list>

#include "Afxsock.h"
#include "zmessage.h"

using namespace std;

struct CommInstrument
{
	string				InstrumentID;
	string				ExchID;
	string				ExchInstrumentID;

	int					Index;

	bool				IsMarketDataSubscribed;
	list<CSocket *>		MarketDataSubcriptionList;

	ZAdaptorMarketDataBestLevelMessage	MarketDataBestLevelSnapshot;
	bool								HasMarketDataBestLevelSnapshot;

	ZAdaptorMarketDataTradeMessage		MarketTradeSnapshot;
	bool								HasMarketDataTradeSnapshot;

	bool								CanPublish;

	CommInstrument();

	void AddSocketToSubscribeList(CSocket *);
	void RemoveSocketFromSubscribeList(CSocket *);
	inline bool HasSubscription() const {return MarketDataSubcriptionList.size() > 0;}
	void PubMarketDataBestLevelSnapshot();
	void PubMarketTradeSnapshot();
};

struct CommInstrumentList {
	CommInstrumentList();
	CommInstrument *GetInstrumentByID(const string &);
	void LoadAllInstrument(string &);
	void RemoveMarketDataSubscriptionFromList(CSocket *);

	list<CommInstrument *> InstrumentList;
};

#endif //COMM_INSTRUMENT_H_